package com.xiaoyu.net.intercept;

import androidx.annotation.NonNull;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

public class RefreshTokenInterceptorProxy implements Interceptor {

    private static Interceptor sRefreshTokenInterceptor;

    public static void setRefreshTokenInterceptor(Interceptor refreshTokenInterceptor) {
        sRefreshTokenInterceptor = refreshTokenInterceptor;
    }

    @Override
    @NonNull
    public Response intercept(@NonNull Chain chain) throws IOException {
        if (sRefreshTokenInterceptor == null) {
            return chain.proceed(chain.request());
        }
        return sRefreshTokenInterceptor.intercept(chain);
    }
}
